﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using YSC_Core.BLL.Domain.CommonModels;
using YSC_Services.BLL.Services.Interfaces;

namespace YSC_App_WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class HomeController : ControllerBase
    {
        private IHomeAppServices _rep;

        public HomeController(IHomeAppServices rep)
        {
            this._rep = rep;
        }


        /// <summary>
        /// 首页活动列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("GetHomeActivityAll")]
        public ActionResult GetHomeActivityAll()
        {
            var ret = _rep.GetHomeActivityAll();
            return Ok(ret);
        }

        /// <summary>
        /// 活动详情
        /// </summary>
        /// <param name="activityId">活动Id</param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetHomeActivity")]
        public ActionResult GetHomeActivity(string activityId)
        {
            var ret = _rep.GetHomeActivity(activityId);
            return Ok(ret);
        }


        /// <summary>
        /// 首页文章列表
        /// </summary>
        /// <param name="intType">0:热门推荐 1:最新资讯/默认为0</param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetHomeNewsArticleAll")]
        public ActionResult GetHomeNewsArticleAll(int intType = 0)
        {
            var ret = _rep.GetHomeNewsArticleAll(intType);
            return Ok(ret);
        }


        /// <summary>
        /// 文章详情
        /// </summary>
        /// <param name="newsId"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetHomeNewsArticle")]
        public ActionResult GetHomeNewsArticle(string newsId)
        {
            var ret = _rep.GetHomeNewsArticle(newsId);
            return Ok(ret);
        }



        /// <summary>
        /// 文章列表
        /// </summary>
        /// <param name="input"></param>
        /// <param name="sasearch">模糊条件:作者 标题</param>
        /// <param name="intType">0:热门推荐 1:最新资讯/默认为0</param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetNewsArticleAll")]
        public ActionResult GetNewsArticleAll(PaginationRequest input, string sasearch, int intType = 0)
        {
            var ret = _rep.GetNewsArticleAll(input.Page, input.PageSize, sasearch, intType);
            return Ok(ret);
        }


        /// <summary>
        /// 首页_实时价格
        /// </summary>
        /// <param name="areaName">地区名称</param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetHomeRealTimeAll")]
        public ActionResult GetHomeRealTimeAll(string areaName)
        {
            var ret = _rep.GetHomeRealTimeAll(areaName);
            return Ok(ret);
        }

        /// <summary>
        /// 实时市场价格列表
        /// </summary>
        /// <param name="input"></param>
        /// <param name="areaName">地区名称</param>
        /// <param name="areaId">区县编码</param>
        /// <param name="priceType">报价类型0:市场价 1：产地价</param>
        /// <returns></returns>
        [HttpPost]
        [Route("GetMarketTimeAll")]
        public ActionResult GetMarketTimeAll(PaginationRequest input, string areaName, string areaId, int priceType = 0)
        {
            var ret = _rep.GetMarketTimeAll(input.Page, input.PageSize, areaName, areaId, priceType);
            return Ok(ret);
        }

    }
}